package com.flyweb.result;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;

import com.flyweb.config.ResultType;

/** <p>Title: flyweb</p>
 *
 *  <p>Description: </p>
 *
 *  <p>CreateTime: 2007-Oct 17, 2007-8:02:16 PM</p>
 * 
 *  @author fireflyc@126.com
 **/
public class ResultTypeFactory {
	public static List<ResultType> getResultTypeList(String filePath){
		List<ResultType> result = new ArrayList<ResultType>();
		Digester digester = new Digester();
		digester.setValidating(false);
		
		digester.push(result);
		digester.addObjectCreate("types/type", "com.flyweb.config.ResultType");
		digester.addSetProperties("types/type");
		digester.addCallMethod("types/type/", "setValue", 0);
		digester.addSetNext("types/type", "add", "com.flyweb.config.ResultType");
		try {
			digester.parse(new File(filePath));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
}
